import 'package:flutter/material.dart';
import 'package:notification_permissions/notification_permissions.dart';

class GetCheckNotification {
    static getCheckNotificationPermStatus(context) {
        return NotificationPermissions.getNotificationPermissionStatus().then((status) {
            print(status);
            
            if(status == PermissionStatus.denied){
                return showDialog(
                    context: context,
                    builder: (context) => new AlertDialog(
                        title: new Text('APP需要获取通知权限'),
                        // content: new Text('空'),
                        actions: <Widget>[
                            new FlatButton(
                                onPressed: () => Navigator.of(context).pop(),
                                child: new Text('取消'),
                            ),
                            new FlatButton(
                                onPressed: (){
                                    Navigator.of(context).pop();
                                    NotificationPermissions.requestNotificationPermissions(const NotificationSettingsIos(sound: true, badge: true, alert: true)).then((_) {});
                                },
                                child: new Text('打开设置获取权限'),
                            ),
                        ],
                    ),
                ) ?? false;
            }else{
                return null;
            }
        });
    }
}

